/*
*类描述：notice管理类
*开发者：sjc
*创建时间：2018-8-19 14:42:36
*/
var ntId;
$(function () {
    if(notice != null && notice != "undefined"){
        $("#labTitle").html(notice.title);
        $("#noticeId").val(notice.id);
    }

    //初始化富文本编辑框
    tinymce.init({
        readonly:true,
        convert_urls: false,
        selector: '.tinymce',
        height: 300,
        plugins: [
            'advlist autolink lists link image charmap print preview anchor',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table contextmenu paste code'
        ],
        toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
        init_instance_callback:getCon
    });

    if(notice != null && notice != "undefined"){
        $("#noticeTitle").val(notice.title);
        $("#noticeId").val(notice.id);
        // $("#noticeType").val(notice.noticeType);
        ntId = notice.id;
        var memberList=new Array();
        memberList=notice.sendIdList;
        sessionStorage.setItem("memberList",JSON.stringify(memberList));
        $("input[type='radio'][name='acceptObj']").eq(0).attr("checked",true);
        if(memberList.length>0 && memberList[0] != "0"){
            $("input[type='radio'][name='acceptObj']").eq(1).attr("checked",true);
        }
        //给富文本编辑器赋值
        // tinyMCE.activeEditor.setContent(notice.content);
        // $(".tinymce").val(notice.content);
        var temp = [];
        //循环读取图片
        if (naList != null && naList != "undefined") {
            $.each(naList, function (i, obj) {
                temp.push(obj.attachmentUrl);
            });
            //初始化图片展示
            $("#case").attr("data-value", temp);
        }
    }

    $("#case").upload(
        function (_this, data) {
            layer.msg("图片链接："+data,{time: 5000},function(){
            });
        }
    )

});

function getCon() {
    if(null != notice && "" != notice && null != notice.content){
        tinyMCE.activeEditor.setContent(notice.content);
    }
    // tinyMCE.activeEditor.setContent(notice.content);
}
